package xx.pro.consumer.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class Consumer {

    /**
     * 正常消息
     * @param message
     */
    @RabbitListener(queues = "direct.queue")
    public void directConsumer(Message message) {
        String msg = new String(message.getBody());
        log.info("Direct Consumer 接收到消息:{}", msg);
        System.out.println(1 / 0);
        log.info("消费者处理消息成功！");
    }


    /**
     * 错误消息
     * @param message
     */
    @RabbitListener(queues = "error.queue")
    public void errorConsumer(Message message) {
        String msg = new String(message.getBody());
        log.info("Error Consumer 接收到消息:{}", msg);
    }
}
